home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 June
/
Macworld (1999-06).dmg
/
Shareware World
/
Info
/
For Developers
/
MacZoop2.0.sea
/
MacZoop2.0
/
Required Classes
/
Main.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-02-08
|
2KB
|
99 lines
/*************************************************************************************************
*
*
* MacZoop 2.0- "the framework for the rest of us"
*
*
*
* Main.c -- start up the app
*
* DO NOT ALTER OR EDIT THIS FILE. In "ProjectSettings.h" for this project, declare
* your application class name and the macros here
* will expand that definition to do the right thing.
*
*
* © 1999, Graham Cox
*
*
*
*
*************************************************************************************************/
#include "ProjectSettings.h"
#include "MacZoop.h"
// MacZoop prefers to handle its own exceptions when an allocation using <new> fails. Older
// CW versions returned NULL in such circumstances, newer ones throw an exception. Since we
// prefer the old way, we need a way to turn off the newer behaviour, but in a way which works
// for all versions of CodeWarrior, and even other compilers. This macro is used to hide the
// details of doing this. <<< MORE TO DO >>>
#if defined(__MWERKS__)
#if __MWERKS__ >= 0x2100 // Pro3
namespace std
{
extern char __throws_bad_alloc;
}
#define NOBADALLOCS std::__throws_bad_alloc = FALSE
#else
#if __MWERKS__ >= 0x1000 // Pro1, Pro 2
extern char __throws_bad_alloc;
#define NOBADALLOCS __throws_bad_alloc = FALSE
#else
#define NOBADALLOCS
#endif
#endif
#else
#define NOBADALLOCS
#endif
// if this isn't defined, make a generic application object by default
#ifndef APP_CLASS_NAME
#define APP_CLASS_NAME ZApplication
#endif
// application construction macro- this allows a standard main() function that only requires
// the user to name their application class in their project settings and bingo- less error
// prone than the MacZoop 1.x method.
#define MAKE_USER_APPLICATION new APP_CLASS_NAME()
// application header macro- makes sure the correct header file is automatically included
#include HEADER( APP_CLASS_NAME )
void main( void );
// Main function:
void main( void )
{
// we'll do the exception handling, thankyou very much....
NOBADALLOCS;
// now... do it!!!
try
{
FailNIL( gApplication = MAKE_USER_APPLICATION );
RunApplication();
}
catch(...)
{
// bloody hellfire!
SysBeep( 1 );
SysBeep( 1 );
SysBeep( 1 );
// make a feeble attempt to clean up gracefully...
if ( gApplication )
ForgetObject( gApplication );
}
}